<template>
    <TechDialog
        class="pick-order-code-modal"
        title="取货码"
        ref="tip"
        @ok="okAction"
        cancelText="关闭"
        okText="确认收货"
        :mode="mode"
        :theme="theme"
        :styleMode="styleMode"
        container="body"
    >
        <div class="pick-up-code-value">
            {{code}}
        </div>
    </TechDialog>
</template>

<script>
import { mapActions } from 'vuex';
import { TechDialog } from '@components/base';
import { DELIVERY_TYPE_TEXT } from '@constants/shop';
import ModeMixin from '@common/mixin';
import EventBus from '@common/eventBus';
import { TipError, TipSuccess } from '@common/tip';
export default {
    name: 'OrderPickUpCode',
    mixins: [ModeMixin],
    components: {
        TechDialog,
    },
    props: {
        code: {
            type: String,
            default: '',
        },
        orderNumber: {
            type: String,
            default: '',
        },
    },
    methods: {
        ...mapActions([
            'confirmOrder',
        ]),
        async okAction() {
            const { orderNumber } = this.$props;
            const flag = await this.confirmOrder(orderNumber);
            flag ? TipSuccess('确认成功！') : TipError('确认失败，请重试！');
            EventBus.$emit('RefreshShopOrderList');
        },
        show() {
            this.$refs.tip.show();
        },
    },
};
</script>

<style lang="less">
.pick-order-code-modal {
    .dialog-content {
        width: 100%;
        display: flex;
    }
    .pick-up-code-value {
        width: 100%;
        .flex-center();
        .font-size(24);
        color: @text-color;
        font-weight: 500;
    }
}
</style>
